//using FireStarterModeller.BO;
//using FirestarterModeller.Test.BO;
//using FireStarterModeller.UI;
//using Habanero.Base;
//using Habanero.BO;
//using Habanero.UI.Base;
//using NUnit.Framework;
//using Rhino.Mocks;
//using ExtendedComboBoxMapper=Habanero.UI.Base.ExtendedComboBoxMapper;

//namespace FireStarterModeller.Test.UI
//{
//    [TestFixture]
//    public class TestExtendedLookupComboBoxMapper : TestBase
//    {
//        private static IControlFactory GetControlFactory()
//        {
//            return GlobalUIRegistry.ControlFactory;
//        }

//        [Test]
//        public void Test_Construct()
//        {
//            //--------------- Set up test pack ------------------
//            IControlFactory controlFactory = GetControlFactory();
//            IExtendedComboBox extendedComboBox = ExtendedComboBoxWin(controlFactory);
//            string propName = TestUtils.GetRandomString();
//            //--------------- Test Preconditions ----------------

//            //--------------- Execute Test ----------------------
//            ExtendedComboBoxMapper mapper = new ExtendedComboBoxMapper(
//                extendedComboBox, propName, false, controlFactory);
//            //--------------- Test Result -----------------------
//            Assert.IsInstanceOfType(typeof(IControlMapper), mapper);
//            Assert.AreSame(extendedComboBox, mapper.Control);
//            Assert.AreEqual(propName, mapper.PropertyName);
//            Assert.AreEqual(false, mapper.IsReadOnly);
//            Assert.AreEqual(controlFactory, mapper.ControlFactory);
//            LookupComboBoxMapper lookupComboBoxMapper = mapper.LookupComboBoxMapper;
//            Assert.IsNotNull(lookupComboBoxMapper);
//            Assert.AreSame(extendedComboBox.ComboBox, lookupComboBoxMapper.Control);
//            Assert.AreEqual(propName, lookupComboBoxMapper.PropertyName);
//            Assert.AreEqual(false, lookupComboBoxMapper.IsReadOnly);
//            Assert.AreEqual(controlFactory, lookupComboBoxMapper.ControlFactory);
//            Assert.AreEqual(lookupComboBoxMapper.ErrorProvider, mapper.ErrorProvider);
//        }

//        [Test]
//        public void Test_Construct_ReadOnly()
//        {
//            //--------------- Set up test pack ------------------
//            IControlFactory controlFactory = GetControlFactory();
//            ExtendedComboBox extendedComboBox = new ExtendedComboBox(controlFactory);
//            string propName = TestUtils.GetRandomString();
//            //--------------- Test Preconditions ----------------

//            //--------------- Execute Test ----------------------
//            ExtendedComboBoxMapper mapper = new ExtendedComboBoxMapper(
//                extendedComboBox, propName, true, controlFactory);
//            //--------------- Test Result -----------------------
//            Assert.IsInstanceOfType(typeof(IControlMapper), mapper);
//            Assert.AreEqual(true, mapper.IsReadOnly);
//            LookupComboBoxMapper lookupComboBoxMapper = mapper.LookupComboBoxMapper;
//            Assert.IsNotNull(lookupComboBoxMapper);
//            Assert.AreEqual(true, lookupComboBoxMapper.IsReadOnly);
//        }

//        [Test]
//        public void Test_SetBusinessObject()
//        {
//            //--------------- Set up test pack ------------------
//            ExtendedComboBoxMapper mapper = CreateExtendedLookupComboBoxMapper();
//            //--------------- Test Preconditions ----------------
//            Assert.IsNull(mapper.BusinessObject);
//            Assert.IsNull(mapper.LookupComboBoxMapper.BusinessObject);
//            BusinessObjectInfo businessObjectInfo = new BusinessObjectInfo();
//            //--------------- Execute Test ----------------------
//            mapper.BusinessObject = businessObjectInfo;
//            //--------------- Test Result -----------------------
//            Assert.AreSame(businessObjectInfo, mapper.BusinessObject);
//            Assert.AreSame(businessObjectInfo, mapper.LookupComboBoxMapper.BusinessObject);
//        }

//        [Test]
//        public void Test_ItemsShowingInComboBox()
//        {
//            //--------------- Set up test pack ------------------
//            TestUtils.CreateSavedProjectAssemblyInfo();
//            TestUtils.CreateSavedProjectAssemblyInfo();
//            IControlFactory controlFactory = GetControlFactory();
//            ExtendedComboBox extendedComboBox = new ExtendedComboBox(controlFactory);
//            string propName = "ProjectAssemblyInfoID";
//            ExtendedComboBoxMapper mapper = new ExtendedComboBoxMapper(
//                extendedComboBox, propName, true, controlFactory);
//            //--------------- Test Preconditions ----------------
//            Assert.IsNull(mapper.BusinessObject);
//            Assert.IsNull(mapper.LookupComboBoxMapper.BusinessObject);
//            BusinessObjectInfo businessObjectInfo = new BusinessObjectInfo();
//            //--------------- Execute Test ----------------------
//            mapper.BusinessObject = businessObjectInfo;
//            //--------------- Test Result -----------------------
//            Assert.AreSame(businessObjectInfo, mapper.BusinessObject);
//            Assert.AreSame(businessObjectInfo, mapper.LookupComboBoxMapper.BusinessObject);
//            Assert.AreEqual(2, mapper.LookupComboBoxMapper.LookupList.Count);
//        }

//        [Test]
//        public void Test_SetBusinessObject_OnInternalLookupComboBoxMapper()
//        {
//            //--------------- Set up test pack ------------------
//            ExtendedComboBoxMapper mapper = CreateExtendedLookupComboBoxMapper();
//            //--------------- Test Preconditions ----------------
//            Assert.IsNull(mapper.BusinessObject);
//            Assert.IsNull(mapper.LookupComboBoxMapper.BusinessObject);
//            BusinessObjectInfo businessObjectInfo = new BusinessObjectInfo();
//            //--------------- Execute Test ----------------------
//            mapper.LookupComboBoxMapper.BusinessObject = businessObjectInfo;
//            //--------------- Test Result -----------------------
//            Assert.AreSame(businessObjectInfo, mapper.BusinessObject);
//            Assert.AreSame(businessObjectInfo, mapper.LookupComboBoxMapper.BusinessObject);
//        }

//        private ExtendedComboBoxMapper CreateExtendedLookupComboBoxMapper()
//        {
//            IControlFactory controlFactory = GetControlFactory();
//            ExtendedComboBox extendedComboBox = new ExtendedComboBox(controlFactory);
//            string propName = TestUtils.GetRandomString();
//            ExtendedComboBoxMapper extendedComboBoxMapper = new ExtendedComboBoxMapper(
//                extendedComboBox, propName, true, controlFactory);
//            return extendedComboBoxMapper;
//        }

//        [Test]
//        public void Test_ApplyChangesToBusinessObject()
//        {
//            //--------------- Set up test pack ------------------
//            IControlFactory controlFactory = GetControlFactory();
//            ExtendedComboBox extendedComboBox = new ExtendedComboBox(controlFactory);
//            string propName = TestUtils.GetRandomString();
//            ExtendedComboBoxMapper mapper = new ExtendedComboBoxMapper(
//                extendedComboBox, propName, true, controlFactory);
//            MockRepository mock = new MockRepository();
//            LookupComboBoxMapper lookupComboBoxMapperMock = mock.DynamicMock<LookupComboBoxMapper>(extendedComboBox.ComboBox, propName, true, controlFactory);
//            Expect.Call(delegate { lookupComboBoxMapperMock.ApplyChangesToBusinessObject(); }).Repeat.Once();
//            mapper.LookupComboBoxMapper = lookupComboBoxMapperMock;
//            mock.ReplayAll();
//            //--------------- Test Preconditions ----------------

//            //--------------- Execute Test ----------------------
//            mapper.ApplyChangesToBusinessObject();
//            //--------------- Test Result -----------------------
//            mock.VerifyAll();
//        }

//        [Test]
//        public void Test_UpdateControlValueFromBusinessObject()
//        {
//            //--------------- Set up test pack ------------------
//            IControlFactory controlFactory = GetControlFactory();
//            ExtendedComboBox extendedComboBox = new ExtendedComboBox(controlFactory);
//            string propName = TestUtils.GetRandomString();
//            ExtendedComboBoxMapper mapper = new ExtendedComboBoxMapper(
//                extendedComboBox, propName, true, controlFactory);
//            MockRepository mock = new MockRepository();
//            LookupComboBoxMapper lookupComboBoxMapperMock = mock.DynamicMock<LookupComboBoxMapper>(extendedComboBox.ComboBox, propName, true, controlFactory);
//            Expect.Call(delegate { lookupComboBoxMapperMock.UpdateControlValueFromBusinessObject(); }).Repeat.Once();
//            mapper.LookupComboBoxMapper = lookupComboBoxMapperMock;
//            mock.ReplayAll();
//            //--------------- Test Preconditions ----------------

//            //--------------- Execute Test ----------------------
//            mapper.UpdateControlValueFromBusinessObject();
//            //--------------- Test Result -----------------------
//            mock.VerifyAll();
//        }
        
//        [Test]
//        public void Test_ShowGridAndBOEditorControlOnClick()
//        {
//            //--------------- Set up test pack ------------------
//            BusinessObjectCollection<ProjectAssemblyInfo> projectAssemblyInfosCollection = TestUtils.CreateSavedProjectAssemblyInfosCollection();
//            IControlFactory controlFactory = GetControlFactory();
//            ExtendedComboBox extendedComboBox = new ExtendedComboBox(controlFactory);
//            string propName = "ProjectAssemblyInfoID";
//            ExtendedComboBoxMapper mapper = new ExtendedComboBoxMapper(
//                extendedComboBox, propName, true, controlFactory);
//            mapper.BusinessObject = new BusinessObjectInfo();
//            //--------------- Test Preconditions ----------------
//            Assert.IsNull(mapper.PopupForm);
//            //--------------- Execute Test ----------------------
//            //extendedComboBox.Button.PerformClick();
//            mapper.ShowPopupForm();
//            //--------------- Test Result -----------------------
//            Assert.IsNotNull(mapper.PopupForm);
//            IFormHabanero form = mapper.PopupForm;
//            Assert.AreEqual(800, form.Width);
//            Assert.AreEqual(600, form.Height);
//            Assert.AreEqual(1, form.Controls.Count);
//            Assert.AreEqual(DockStyle.Fill, form.Controls[0].Dock);

//            Assert.IsInstanceOfType(typeof(IGridAndBOEditorControl), form.Controls[0]);
//            Assert.IsInstanceOfType(typeof(GridAndBOEditorControl<ProjectAssemblyInfo>), form.Controls[0]);
//            GridAndBOEditorControl<ProjectAssemblyInfo> gridAndBOEditorControl = (GridAndBOEditorControl<ProjectAssemblyInfo>) form.Controls[0];
//            //Assert.AreSame(mapper.BusinessObject, gridAndBOEditorControl.BusinessObjectControl.BusinessObject);
//            Assert.IsTrue(gridAndBOEditorControl.ReadOnlyGridControl.IsInitialised);
//            IBusinessObjectCollection collection = gridAndBOEditorControl.ReadOnlyGridControl.Grid.GetBusinessObjectCollection();
//            Assert.IsNotNull(collection);
//            Assert.AreEqual(projectAssemblyInfosCollection.Count, collection.Count);
//            Assert.AreEqual(projectAssemblyInfosCollection.Count, mapper.LookupComboBoxMapper.LookupList.Count);
//        }

//    }


//}